package com.oa.srms.apps.dao.pay.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oa.srms.apps.dao.pay.IPayInfoDao;
import com.oa.srms.apps.entity.pay.PayInfoValue;

public class PayInfoDaoImpl extends HibernateDaoSupport implements IPayInfoDao {
	
	@Override
	public Integer addPayInfo(PayInfoValue payInfoValue) throws Exception {
		if(payInfoValue != null){
			this.getHibernateTemplate().save(payInfoValue);
		}
		return payInfoValue.getId();
	}

	@Override
	public void editPayInfo(PayInfoValue payInfoValue) throws Exception {
		if(payInfoValue != null){
			this.getHibernateTemplate().update(payInfoValue);
		}
	}

	@Override
	public PayInfoValue queryById(Integer id) throws Exception {
		return (PayInfoValue) this.getHibernateTemplate().get(PayInfoValue.class, id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PayInfoValue> queryPayInfo(String cardId) throws Exception {
		String hql = "FROM PayInfoValue piv WHERE piv.cardId = ?";
		return this.getHibernateTemplate().find(hql, cardId);
	}

}
